/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

/**
 *
 * @author Minh Luc
 */
public class Validate {

    public static boolean isEmpty(String text) { // Not Null
        if (text.trim().isEmpty()) {
            return true;
        }
        return false;
    }

    public static boolean isCharacter(String text) { // Letter co khoang trang
        if (text.matches("^[a-zA-Z]+([\\s][a-zA-Z]+)*$")) {
            return true;
        }
        return false;
    }

    public static boolean isContent(String text) { // Character co khoang trang
        if (text.matches("^[a-zA-Z0-9]+([\\s][a-zA-Z0-9]+)*$")) {
            return true;
        }
        return false;
    }

    public static boolean isContent2(String text) { // Character khong khoang trang
        if (text.matches("^[a-zA-Z0-9]+$")) {
            return true;
        }
        return false;
    }

    public static boolean isFloat(String text) { // only Number Float
        if (text.matches("^[0-9]+(\\.[0-9]+)*$")) {
            return true;
        }
        return false;
    }

    public static boolean isInt(String text) { // only Number Int
        if (text.matches("^[0-9]+$")) {
            return true;
        }
        return false;
    }

    public static boolean isValidEmail(String email) { //Email
        if (email.matches("^[a-zA-Z]+((\\_|\\.)*[a-zA-Z0-9]+)*\\@([a-zA-Z]+\\.)+[a-zA-Z]{2,4}$")) {
            return true;
        }
        return false;
    }

    public static boolean check5Charater(String text) { // ky tu < 5
        if (text.trim().length() < 5) {
            return false;
        } else {
            return true;
        }
    }

    public static boolean isChar(String text) { // Letter khong khoang trang
        if (text.matches("^[a-zA-Z]+$")) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isPhone(String text) { // PhoneNumber
        if (text.matches("^[0-9]+$") && text.length() >= 8 && text.length() <= 14) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isBankNumber(String text) { // BankNumber
        if (text.matches("^[0-9]+$") && text.length() >= 12 && text.length() <= 16) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isRssLink(String rssLink) { //Email
        if (rssLink.matches("^(https?://)?[a-zA-Z0-9\\-]+[.a-zA-Z0-9\\-/]+$")) {
            return true;
        }
        return false;
    }
}
